$(function () {
    var t = "pop-in";
    mui("body").on("tap", "a", function () {
        var e = this.getAttribute("href"), a = this.href;
        mui.openWindow({id: e, url: a, styles: {popGesture: "close"}, show: {aniShow: t}, waiting: {autoShow: !0}})
    });
    var e = new common;
    e.getJsonObj(sessionStorage.getItem("msJson"));
    $("#date_choose").text(e.date.Format("MM月dd日")), $("#to-time").attr("data-value", e.date.Format("yyyy-MM-dd"));
    var a = new Date($("#to-time").attr("data-value")), n = $(".date-number").text();
    a.setDate(a.getDate() + parseInt(n)), $("#leave_date").text(a.Format("yyyy-MM-dd") + "退房"), mui("body").on("tap", ".data_in_pic2", function () {
        var t = $(".date-number").text(), e = parseInt(t) + 1;
        if (0 !== e && 1e3 !== e) {
            $(".date-number").text(e);
            var a = new Date($("#to-time").attr("data-value")), n = $(".date-number").text();
            a.setDate(a.getDate() + parseInt(n)), $("#leave_date").text(a.Format("yyyy-MM-dd") + "退房")
        }
    }), mui("body").on("tap", ".data_in_pic1", function () {
        var t = $(".date-number").text(), e = parseInt(t) - 1;
        if (0 !== e) {
            $(".date-number").text(e);
            var a = new Date($("#to-time").attr("data-value")), n = $(".date-number").text();
            a.setDate(a.getDate() + parseInt(n)), $("#leave_date").text(a.Format("yyyy-MM-dd") + "退房")
        }
    });
    var o = $("#to-time");
    o.each(function (t, a) {
        a.addEventListener("tap", function () {
            var t = this.getAttribute("data-options") || '{"type":"date"}', a = this.getAttribute("data-value") || "", n = JSON.parse(t);
            n.beginDate = e.date;
            var o = new Date;
            o.setDate(o.getDate() + 180), n.endDate = o, n.value = a;
            var i = this.getAttribute("id"), r = new mui.DtPicker(n);
            r.show(function (t) {
                var a = $("#" + i);
                a.attr("data-value", t.value), a.find(".date").text(t.m.text + "月" + t.d.text + "日"), a.find(".week").text(e.getWeek(t.text));
                var n = t.text, o = new Date(n), d = $(".date-number").text();
                o.setDate(o.getDate() + parseInt(d)), $("#leave_date").text(o.Format("yyyy-MM-dd") + "退房"), r.dispose()
            })
        }, !1)
    }), $("#inputForm").html5Validate(function () {
        var t = {}, a = e.strToObj(decodeURIComponent($(this).serialize(), !0)), n = new Date($("#to-time").attr("data-value")), o = n.Format("yyyy-MM-dd"), i = parseInt($(".date-number").text());
        a ? (t.checkInTime = o, t.checkInDays = i, t.applyName = a.applyName, t.applyMobile = a.applyMobile, t.applyIdcard = a.applyIdcard, t.applyEmail = a.applyEmail, sessionStorage.setItem("msJson", JSON.stringify(t)), setTimeout(function () {
            mui.openWindow({
                id: "booking-region.html",
                url: "booking-region.html",
                styles: {popGesture: "close"},
                show: {aniShow: "pop-in"},
                waiting: {autoShow: !0}
            })
        }, 100)) : mui.toast("转化异常!")
    }), mui("body").on("tap", ".footer-button", function () {
        $("#inputForm").submit()
    })
});